{% block content %}
        <script type="text/javascript">
      // when passed a function, jQuery execs code when DOM Ready
      $(function() {
            
                $('#tabs').tabs({
    load: function(event, ui) {
        $(ui.panel).delegate('a', 'click', function(event) {
            $(ui.panel).load(this.href);
            event.preventDefault();
        });
    }
});
            
          });
        </script>
    <h2>
        {{tournament}}
        {% if user in tournament.owners.all %}
            <a href="/bouting/{{tournament.id}}/createEvent/">+Event</a>
            <a href="/bouting/{{tournament.id}}/editTournament/">Edit</a>
            <a href="/bouting/{{tournament.id}}/deleteTournament/">Delete</a>
            <button>Import</button>
        {% endif %}
    </h2>
    <p>
        <h4>Location</h4>
        {{tournament.street}}<br>
        {{tournament.city}}, {{tournament.state}}
    </p>
    <ul>
        {% for event in eventList%}
            <li>
                {{event}}
                {% if user in tournament.owners.all %}
                    {% if event.status < 3%}
                        <a href="/bouting/{{tournament.id}}/{{event.id}}/confirmEntrants/">Begin</a>
                        <a href="/bouting/{{tournament.id}}/{{event.id}}/editEvent/">Edit</a>
                        <a href="/bouting/{{tournament.id}}/{{event.id}}/deleteEvent/">Remove</a>
                    {% endif %}
                {% endif %}
                {% if event.status >= 3%}
                    - In Progress
                {% endif %}
                    
                
            </li>
            <ul>
                <li>Start: {{event.start}}</li>
                <li>Entrants
                    <ul>
                        {% for entrant in event.getEntrants %}
                            <li>
                                {{entrant}}
                                {% if event.limitWeapon == "Foil" %}
                                    {{entrant.identity.getFoilRating}}
                                {% endif %}
                                {% if event.limitWeapon == "Epee" %}
                                    {{entrant.identity.getEpeeRating}}
                                {% endif %}
                                {% if event.limitWeapon == "Saber" %}
                                    {{entrant.identity.getSaberRating}}
                                {% endif %}
                                {{entrant.identity.primaryClub.abbreviation}}
                                {% if user in tournament.owners.all or entrant.identity == person %}
                                    {% if event.status < 3%}
                                        <a href="/bouting/{{tournament.id}}/{{event.id}}/{{entrant.id}}/deleteEntrant/">X</a>
                                    {% endif %}
                                {% endif %}
                            </li>
                        {% endfor %}
                        {% if event.status < 3%}
                        <form id="Entrant-{{event.id}}" action={% block entrantDestination %}"/bouting/{{tournament.id}}/{{event.id}}/createEntrant/"{% endblock %} method="post">
                            {% csrf_token %}
                            <li>
                                {% if user in tournament.owners.all %}
                                    <select id="id_identity" name="identity">
                                        {% for possible in event.getPossibleEntrants %}
                                            <option value="{{possible.id}}">
                                                {{possible}}
                                                {% if event.limitWeapon == "Foil" %}
                                                    {{possible.getFoilRating}}
                                                {% endif %}
                                                {% if event.limitWeapon == "Epee" %}
                                                    {{possible.getEpeeRating}}
                                                {% endif %}
                                                {% if event.limitWeapon == "Saber" %}
                                                    {{possible.getSaberRating}}
                                                {% endif %}
                                                {{possible.primaryClub.abbreviation}}
                                            </option>
                                        {% endfor %}
                                    </select>
                                    <input type='submit' value="Enter"/>
                                {% endif %}
                                {% if person and not user in tournament.owners.all and not person.id in event.getEntrantIdentities %}
                                    <i>{{person}}</i>
                                    <input type='hidden' id='id_identity' name='identity' value='{{person.id}}'/>
                                    <input type='submit' value="Enter"/>
                                {% endif %}
                                {% if user in tournament.owners.all %}
                                    <button type='button' class='newPerson'>New Person</button>
                                {% endif %}
                            </li>
                        </form>
                        {% endif %}
                    </ul>
                </li>
                <li>Referees
                    <ul>
                        {% for ref in event.getReferees%}
                            <li>{{ref}} <a href="/bouting/{{tournament.id}}/{{event.id}}/{{ref.id}}/deleteRef/">X</a></li>
                        {% endfor %}
                        {% if event.status < 3%}
                        <form id="Ref-{{event.id}}" action={% block refDestination %}"/bouting/{{tournament.id}}/{{event.id}}/createRef/"{% endblock %} method="post">
                            {% csrf_token %}
                            <li>
                                {{refForm.identity}}
                                <input type='submit' value="Enter"/>
                                {% if user in tournament.owners.all %}
                                    <button type='button' class='newPerson'>New Person</button>
                                {% endif %}
                            </li>
                        </form>
                        {% endif %}
                    </ul>
                </li>
            </ul>
        {% empty %}
            <li>No events! Why not add some?</li>
        {% endfor %}
    </ul>
{% endblock %}